Interfacing with JavaScript


You can control 1 Cool Button Tool applets from JavaScript using these methods:

  int BtnPlayer.getState(String buttonName)

  void BtnPlayer.setState(String buttonName, int state)



buttonName is the name of the Button you want to change, or query.

Button state values are allocated as follows:

  state = 0: The button is in the up state.
  state = 1: The button is in the mouse-over state.
  state = 2: The button is in the down state.


JavaScript Example

The example below shows how an HTML button can change the state of 1 Cool Button Tool Button.

First a JavaScript variable called MyButton is declared, and set to the string "Button 1".   Then an HTML button is created, with an "onclick" parameter that specifies the code to be called when the button is pressed.

When the HTML button is clicked it sets the state of "Button 1" to the value 2, or the down state.



< SCRIPT LANGUAGE="JavaScript" > MyButton = "Button 1" < /SCRIPT >

< input TYPE=button width=200 value="Click here to change state."
  onclick="document.BtnPlayer.setState(MyButton, 2)" >


Try copying and pasting this HTML code into your own applet to see how button applets can controlled from JavaScript.

Note: You should set the value of MyButton to the name of a button in your button project.